﻿{include file="Main/menu" /}
<form method="post" class="padding">
	<div class="panel admin-panel" style="background: #fff">
		<div class="panel-head"><strong>{:lang('currency')['edit']}{:lang('label')['category']}</strong></div>
		<div class="padding border-bottom">
			<a type="button" class="button button border-green addcat" href="#" />{:lang('currency')['add']}{:lang('label')['category']}</a>
		</div>
		<table class="table table-hover">
			<tr>
				<th width="100">{:lang('label')['image']}</th>
				<th width="100">{:lang('label')['title']}</th>
				<th width="120">{:lang('label')['sub']}</th>
				<th width="60">{:lang('label')['flag']}</th>
				<th width="100">{:lang('label')['handle']}</th>
			</tr>
			{volist name="data" id="volist"}
				<tr>
					<td style="line-height:40px"><input readonly id="scimage{$volist.title}" data-id="{$volist.id}" type="text" class="hidden"><img data-id="scimage{$volist.title}" class="upload" height="30px" src="{$volist.image}"/></td>
					<td style="line-height:40px"><strong>{$volist.title}</strong></td>
					<td style="line-height:40px">----</td>
					<td></td>
					<td style="line-height:40px"><a class="button border-blue button-little editcat" data-id="{$volist.id}">{:lang('currency')['edit']}</a> <a class="button border-yellow button-little delcat" data-id="{$volist.id}" >{:lang('currency')['del']}</a></td>
				</tr>
			{/volist}
		</table>
	</div>
</form>
<script>
layer.config({
	extend: 'extend/layer.ext.js'
});
$('.flagcat').click(function () {
	var mythis = $(this)
	var str =  mythis.attr('data-id');
	var id = str.split("&")[0];
	var flag = str.split("&")[1];
	layer.open({
		type: 2,
		title:'',
		area: ['350px', '260px'], //宽高
		content: '__URL__/flag_edit.html?id='+id
	});
})
$('.delcat').click(function(){
	var mythis = $(this)
	var id =  mythis.attr('data-id');
	layer.confirm("{:lang('tip')['category_del']}", {
	  btn: ["{:lang('currency')['status_1']}","{:lang('currency')['status_2']}"] //按钮
	}, function(){
		$.getJSON("__ROOT__/admin/service/category_del.html?id="+id,function(data){
			if(data.code == 'success'){
				msg(data.msg,1);
				location.reload();
			}
		});
	});
});
$('.addcat').click(function(){
	layer.open({
		type: 2,
		title:'',
		area: ['350px', '260px'], //宽高
		content: '__URL__/category_edit.html'
	});
});
$('.addcatsub').click(function(){
	var mythis = $(this)
	var gid = mythis.attr('data-id');
	layer.open({
		type: 2,
		area: ['350px', '260px'], //宽高
		content: '__URL__/category_edit.html?gid='+gid
	});
});
$('.editcat').click(function(){
	var mythis = $(this)
	var id = mythis.attr('data-id');
	layer.open({
		type: 2,
		title:'',
		area: ['350px', '260px'], //宽高
		content: '__URL__/category_edit.html?id='+id
	});
});
function uploadfunc(id){
	var url = $("#"+id).val();
	var dataid = $("#"+id).attr('data-id');
	$("#"+id).parent().find('img').attr('src',url);
	$.post("__ROOT__/admin/service/category_edit.html?id="+dataid,{image:url},function(data){
		if(data.code == 'success'){
			msg(data.msg,1);
		}
	});
}
</script>
{include file="Main/menu_footer" /}